home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / dev / src / wangisrc.lha / wangi / units / MRexx.PAS < prev    next >
Pascal/Delphi Source File  |  1995-01-18  |  1KB  |  58 lines

  1. Unit MRexx;
  2.  
  3. INTERFACE
  4.  
  5. Uses
  6.     Exec, Rexx;
  7.     
  8. Procedure SendARexxCommand(command, destport : string);
  9.  
  10.  
  11. IMPLEMENTATION
  12.  
  13. Procedure SendARexxCommand;
  14.  
  15.  
  16. VAR
  17.     rxmsg         : pRexxMsg;
  18.     ap, dummyport : pMsgPort;
  19.     dummsg        : pMessage;
  20.     dp            : string;
  21.     
  22. Begin
  23.     dp := destport + #0;
  24.     if (RexxSysBase <> NIL) and (command <> '') and (destport <> '') then begin
  25.         { rexx available, command and port reasonably valid }
  26.         dummyport := CreateMsgPort;
  27.         if dummyport <> NIL then begin
  28.             { create an ARexx message }
  29.             rxmsg := CreateRexxMsg(DummyPort,NIL,NIL);
  30.             if rxmsg <> NIL then begin
  31.                 { create an argument string }
  32.                 rxmsg^.rm_Args[0] := CreateArgstring(@command[1],length(command));
  33.                 if rxmsg^.rm_Args[0] <> NIL then begin
  34.                     rxmsg^.rm_Action := RXCOMM|RXFF_NOIO;
  35.                     { make sure port does not disapear }
  36.                     Forbid;
  37.                     { find the destination port }
  38.                     ap := FindPort(@dp[1]);
  39.                     if ap <> NIL then
  40.                         { send the message }
  41.                         PutMsg(ap, pMessage(rxmsg));
  42.                     Permit;
  43.                     if ap <> NIL then begin
  44.                         { wait for message and remove }
  45.                         dummsg := WaitPort(DummyPort);
  46.                         dummsg := GetMsg(DummyPort);
  47.                     end;
  48.                     ClearRexxMsg(rxmsg,1);
  49.                 end;
  50.                 DeleteRexxMsg(rxmsg);
  51.             end;
  52.             DeleteMsgPort(dummyport);
  53.         end;
  54.     end;
  55. end;
  56.  
  57. End.
  58.